package week6;

import java.util.ArrayList;
import java.util.Scanner;

public class PP0801 {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int num;
        int[] numbers = new int[51];
        ArrayList<Integer> number = new ArrayList<Integer>();

        System.out.print("输入一个数字0~50(之外退出)： ");//此处灵感来自王文彬同题,利用数组进行统计.
        num = scan.nextInt();
        number.add(num);
        while (num >= 0 && num <= 50) {
            numbers[num]++;
            System.out.print("输入一个数字0~50：");
            num=scan.nextInt();
            if (num >=0 && num <= 50)
                number.add(num);
        }

        System.out.println(number + "其中");
        for (int index = 0; index < numbers.length; index++){
            if (numbers[index] == 0)//去掉没有的数
                continue;
            System.out.println(index + "出现了" + numbers[index] + "次.");
        }
    }
}

